/**
 * 
 */
package com.qolome.vo;

import java.io.Serializable;

import com.qolome.enums.ResultEnum;

import lombok.Data;

/**
 * @Description: 统一返回结果 
 * @author 姜锋
 * @date 2020年1月20日 下午3:59:52 
 * @version V1.0   
 *
 */
@Data
public class ResultVO<T> implements Serializable {


    /**
	 * 
	 */
	private static final long serialVersionUID = -2810764575088756332L;

	/** 错误码. */
    private Integer code;

    /** 提示信息. */
    private String msg;

    /** 具体内容. */
    private T data;

    private ResultVO(ResultEnum resultEnum) {
        this.code = resultEnum.getCode();
        this.msg = resultEnum.getMessage();
    }

    private ResultVO (Integer code,String msg) {
        this.code = code;
        this.msg = msg;
    }

    private ResultVO(ResultEnum resultEnum, T data) {
        this.code = resultEnum.getCode();
        this.msg = resultEnum.getMessage();
        this.data = data;
    }

    public static ResultVO<Void> operator(Integer code,String msg) {
        return new ResultVO<Void>(code,msg);
    }

    public static ResultVO<Void> success() {
        return new ResultVO<Void>(ResultEnum.SUCCESS);
    }

    public static<T>ResultVO<T> success(T data) {
        return new ResultVO<T>(ResultEnum.SUCCESS, data);
    }
}